var Browser = new Object();

Browser.isMozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument != 'undefined');
Browser.isIE = window.ActiveXObject ? true : false;
Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox") != - 1);
Browser.isSafari = (navigator.userAgent.toLowerCase().indexOf("safari") != - 1);
Browser.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera") != - 1);

function confirmurl(url,message) {
	if(confirm(message)) redirect(url);
}
function redirect(url) {
	location.href = url;
}
//滚动条
$(function(){
	//$(":text").addClass('input-text');
})

function rowindex(tr)
{
  if (Browser.isIE)
  {
    return tr.rowIndex;
  }
  else
  {
    table = tr.parentNode.parentNode;
    for (i = 0; i < table.rows.length; i ++ )
    {
      if (table.rows[i] == tr)
      {
        return i;
      }
    }
  }
}

/**
 * 全选checkbox,注意：标识checkbox id固定为为check_box
 * @param string name 列表check名称,如 uid[]
 */
function selectall(name) {
	if ($("#check_box").attr("checked")==true) {
		$("input[name='"+name+"']").each(function() {
  			$(this).attr("checked","checked");
			
		});
	} else {
		$("input[name='"+name+"']").each(function() {
  			$(this).removeAttr("checked");
		});
	}
}
function openwinx(url,name,w,h) {
	if(!w) w=screen.width-4;
	if(!h) h=screen.height-95;
    window.open(url,name,"top=100,left=400,width=" + w + ",height=" + h + ",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no");
}
//弹出对话框
function omnipotent(id,linkurl,title,close_type,w,h) {
	if(!w) w=700;
	if(!h) h=500;
	art.dialog({id:id,iframe:linkurl, title:title, width:w, height:h, lock:true},
	function(){
		if(close_type==1) {
			art.dialog({id:id}).close()
		} else {
			var d = art.dialog({id:id}).data.iframe;
			var form = d.document.getElementById('dosubmit');form.click();
		}
		return false;
	},
	function(){
			art.dialog({id:id}).close()
	});void(0);
}
//TAB切换
function SwapTab(name,cls_show,cls_hide,cnt,cur){
	for(i=1;i<=cnt;i++){
		if(i==cur){
			 $('#div_'+name+'_'+i).show();
			 $('#tab_'+name+'_'+i).attr('class',cls_show);
		}else{
			 $('#div_'+name+'_'+i).hide();
			 $('#tab_'+name+'_'+i).attr('class',cls_hide);
		}
	}
}
function LanguageTab(name,cls_show,cls_hide,cnt,cur){
	for(i=1;i<=cnt;i++){
		if(i==cur){
			 $('#div_lang_'+name+'_'+i).show();
			 $('#lang_'+name+'_'+i).attr('class',cls_show);
		}else{
			 $('#div_lang_'+name+'_'+i).hide();
			 $('#lang_'+name+'_'+i).attr('class',cls_hide);
		}
	}
}
//图片预览
function showImage(filepath) {
	window.top.art.dialog({title:'预览',fixed:true, content:'<img src="'+filepath+'" onload="$(this).LoadImage(true, 500, 500,\'/statics/images/nopic.gif\');"/>'});	
}
$(function(){
	//xheditor编辑器上传图片
	if ($.xheditor) {
	  $('textarea.editor').xheditor({forcePtag:false, width:'80%',height:'200px',html5Upload:false,upImgUrl:"gpadmin.php?m=site&a=public_editor_upload"});
	}
});

//页码跳转
function selectPage(obj,pageRows)
{
	var page = parseInt($(obj).val());
	if(isNaN(page)){
		return false;
	}
	url = window.location.href;
	 if (url.indexOf("&p=")>0)
   {
	   url = url.substring(0,url.indexOf("&p="));
   }
	location.href=url+'&p='+page+'&pageRows='+pageRows;
}
function selectPageRows(obj)
{
	var pageRows = parseInt($(obj).val());
	if(isNaN(pageRows)){
		return false;
	}
	url = window.location.href;
	 if (url.indexOf("&pageRows=")>0)
   {
	   url = url.substring(0,url.indexOf("&pageRows="));
   }
	location.href=url+'&pageRows='+pageRows;
}

//table排序
function sortTable(order, sort)
{
	url = window.location.href;
	 if (url.indexOf("&order_by=")>0)
   {
	   url = url.substring(0,url.indexOf("&order_by="));
   }
	location.href=url+'&order_by='+order+'&sort_by='+sort;
}